package br.com.caelum.vraptor.controller;

import java.util.List;

import javax.inject.Inject;

import br.com.caelum.vraptor.Controller;
import br.com.caelum.vraptor.Result;
import br.com.caelum.vraptor.auth_annotations.Administrador;
import br.com.caelum.vraptor.auth_annotations.Restrito;
import br.com.caelum.vraptor.dao.GenericDAO;
import br.com.caelum.vraptor.entidades.Monitor;

@Controller
public class MonitorController {
	
	@Inject
    private Result result;
    
    @Inject
    private GenericDAO<Monitor> dao;
    
    public void add(){
            
    }
    @Restrito
    public List<Monitor> list(){
            return dao.find();
    }
    @Administrador
    public void save(Monitor monitor){
            dao.save(monitor);
            result.redirectTo(this).list();
    }
    @Administrador
    public Monitor edit(Integer id){
        return dao.find(id);
    }
    @Administrador
    public void delete(int id){
    	Monitor monitor= new Monitor();
        monitor.setId(id);
        dao.delete(monitor);
        result.redirectTo(this).list();
    }


}
